package com.jz.dao.impl;

import com.jz.dao.BaseDao;
import com.jz.dao.CourseDetailDao;
import com.jz.entity.CourseDetail;

import java.util.List;

public class CourseDetailDaoImpl extends BaseDao<CourseDetail> implements CourseDetailDao {
    //增删改查不用穿class,直接传sql,跟参数,如果参数传了,就不用了在=再传了,返回的都是int

    @Override
    public int addCourseDetail(CourseDetail c) {
        String sql = "insert into coursedetail(name,type,url,start_data,cid)values(?,?,?,?,?)";
        Object [] params = {c.getName(),c.getType(),c.getUrl(),c.getStart_date(),c.getCid()};
        return update(sql,params);

    }
 //删除章节
    @Override
    public int delCourseDetail(String cids) {
        String sql = "delete from coursedetail where cid in("+cids+")";
        return update(sql);

    }
  //查询章节
    @Override
    public List<CourseDetail> queryCourseDetailById(String cids) {
        String sql = "select * from coursedetail where cid in("+cids+")";
        return queryMore(sql,CourseDetail.class);

    }
}
